<template>
  <div class="container">
    <text class="big-title">示例</text>
    <web class="webview" src="http://cn.bing.com/" ref="webview"></web>
    <div class="row">
      <div class="btn" @click="back"><text class="btn-text">后退</text></div>
      <div class="btn" @click="refresh"><text class="btn-text">刷新</text></div>
      <div class="btn" @click="forward"><text class="btn-text">前进</text></div>
    </div>
    <text class="big-title">文档</text>
    <div class="button" @click="showDoc"><text class="btn-text">点击查看文档</text></div>
  </div>
</template>

<style scoped>
.container {
  padding: 10px;
}
.big-title {
  color: black;
  font-size: 50px;
  font-weight: bold;
  margin-bottom: 20px;
  margin-top: 20px;
}
.webview {
  height: 500px;
}
.btn {
  border-width: 2px;
  border-radius: 8px;
  border-color: blue;
  padding-left: 30px;
  padding-right: 30px;
  padding-top: 15px;
  padding-bottom: 15px;
  background-color: transparent;
  margin-left: 10px;
  margin-right: 10px;
  margin-top: 20px;
}
.btn:active {
  background-color: #ECECEC;
}
.row {
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.button {
  height: 60px;
  justify-content: center;
  opacity: 1.0;
}
.button:active {
  opacity: 0.6;
}
.btn-text {
  font-size: 30px;
  color: blue;
}
</style>

<script>
  import utils from '../utils.js';
  let navigator = weex.requireModule('navigator');
  let webview = weex.requireModule('webview');
  export default {
    methods: {
      back() {
        webview.goBack(this.$refs.webview);
      },
      refresh() {
        webview.reload(this.$refs.webview);
      },
      forward() {
        webview.goForward(this.$refs.webview);
      },
      showDoc() {
        navigator.push({
          url: utils.getDocDetailUrl(weex.config.bundleUrl),
          animated: true
        });
      }
    }
  }
</script>
